<?php
    class Archives_model extends CI_Model {

        function __construct()
        {
            parent::__construct();
        }

        //新增文章
        function archives_save_add($data)
        {
            $this->db->insert('crazy_archives', $data); 
        }

        //搜索
        function get_search($query)
        {
            return $this->db->query($query);
        }
        
        //根据ID获取一条记录
        function get_archives_by_id_one($id)
        {
              return $this->db->from('crazy_archives')->where('id',$id)->get()->row();
        }
        
		
		  //根据分类ID获取列表
        function get_archives_by_typeid($typeid)
        {
              return $this->db->from('crazy_archives')->where('typeid',$typeid)->get();
        }
		
         //编辑文章
        function get_archives_modify($id,$data)
        {
            $this->db->where('id', $id);
            $this->db->update('crazy_archives', $data); 
        }
        
        //获取自定义属性所有列表
        function get_arcatt_all()
        {
             return $this->db->get('crazy_arcatt');
        }
        
         //删除文章
        function get_archives_del($id)
        {
            $this->db->where('id', $id);
            $this->db->delete('crazy_archives'); 
        }

    }
?>